package top.xiequanquan.groupcode.system.util.logger;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.Map;

/**
 * @author XQQ
 * @create 2019-05-27 14:26
 * @desc 日日志工具类
 **/
public class LoggerUtil {

    /**
     * 保存已经打印过日志的类
     */
    private static Map<Class, Logger> map;
    static {
        map=new HashMap<>();
    }

    /**
     * 初始化Logger
     * @param c 类
     * @return
     */
    public static Logger getLogger(Class c) {
        Logger log = map.get(c);
        if(log != null){
            return log;
        }
        //可以用以后日志扩展修改
        log = LoggerFactory.getLogger(c);
        map.put(c, log);
        return log;
    }
}
